Skip to content

feat(broker): fail-closed scope source + honest kit doctor line (Pillar 3 steps 2–3) - #304

Merged
sandstream merged 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a
Jul 10, 2026
Merged

sandstream merged 1 commit into
mainfrom
claude/web-kit-status-sync-p6fg9a

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Description

Steps 2–3 of the Pillar 3 exec-broker (design: kit-research/docs/research/pillar3-exec-broker-5.0.md §3.2). The broker's SCOPE comes from exactly one place — the profile's signed [scope]/RoE — and this PR adds the enforcement-facing wrapper plus its honest kit doctor surface. Still no enforcement (that's step 4, the PreToolUse gates).

Type of Change

  • New feature (non-breaking change that adds functionality)

Related Issues

Changes Made

  • src/broker/decide.ts:
    • brokerScope(cwd) — never-throws: any error along the trust path (malformed profile, unreadable sig, forged/revoked signature) resolves to null, and a null scope grants nothing. An exception in the trust path is a deny, not a bypass.
    • brokerStatus(cwd) — honest posture: verified (scope governs) / unsigned (declared but not attributable — grants nothing) / invalid (tampered / revoked / malformed — grants nothing) / none (no RoE declared).
  • src/doctor.ts — exec-broker scope check: pass (verified, with scope summary), skip (none, with a how-to-arm hint), warn (unsigned; run kit profile sign), fail (invalid). Same honest-degradation posture as the identity-keystore row: "enforced" must never silently mean "no-op".
  • src/broker/decide.test.ts — 8 tests via a throwaway KIT_IDENTITY_DIR (status across none / no-scope / unsigned / verified / tampered / malformed; brokerScope fail-closed null across absent / unsigned / tampered / malformed).

Testing

Test Coverage

  • Added new tests (8)
  • All tests pass (npm test) — full suite 2685 pass / 0 fail (2677 baseline + 8); doctor tests unaffected (name-based assertions)

Manual Testing

  1. npx tsc --noEmit → clean.
  2. npx eslint src → 0 errors.
  3. npm run build && node scripts/test.mjs → 2685 pass, 0 fail.
  4. npx prettier --check → formatted.

Breaking Changes

None / N/A — new module + one additive doctor row.

Checklist

  • All new code has test coverage
  • All tests pass locally (npm test)
  • No new warnings or errors introduced
  • No hardcoded secrets or sensitive data
  • Code has been self-reviewed

Performance Impact

  • No performance impact — one local file read + offline signature verify in kit doctor

Reviewer Notes

The distinction worth checking is unsigned (warn) vs invalid (fail) in doctor: a declared-but-unsigned scope is an incomplete setup (warn + actionable hint), while a tampered/revoked signature or malformed profile is a broken trust artifact (fail). Both grant nothing at enforcement time — the doctor severity only differentiates operator action. Next step (4): the PreToolUse enforcers (gate-egress/fs/secret) consuming brokerScope + the pure predicates from #303.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2


Generated by Claude Code

…ar 3 steps 2-3)

The broker's SCOPE comes from exactly one place: the profile's signed [scope]/RoE via
verifiedScope (Pillar 4). This adds the enforcement-facing wrapper + status surface
(design: pillar3-exec-broker-5.0.md §3.2):

- broker/decide.ts:
  - brokerScope(cwd): never-throws — any error along the trust path (malformed profile,
    unreadable sig, forged/revoked signature) resolves to null, and a null scope GRANTS
    NOTHING. An exception in the trust path is a deny, not a bypass.
  - brokerStatus(cwd): honest posture — verified (scope governs) / unsigned (declared but
    not attributable — grants nothing) / invalid (tampered/revoked/malformed — grants
    nothing) / none (no RoE declared).
- doctor.ts: 'exec-broker scope' check — pass (verified), skip (none, with how-to-arm hint),
  warn (unsigned; run kit profile sign), fail (invalid). 'Enforced' must never silently mean
  'no-op'; degradation is surfaced, never swallowed — same posture as the identity-keystore row.

8 tests via a throwaway KIT_IDENTITY_DIR (none/no-scope/unsigned/verified/tampered/malformed
for status; fail-closed null across absent/unsigned/tampered/malformed for brokerScope).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
@github-actions

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream
sandstream merged commit c299eb8 into main Jul 10, 2026
18 checks passed
@sandstream
sandstream deleted the claude/web-kit-status-sync-p6fg9a branch July 10, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants